home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / monitor_cache.h < prev    next >
C/C++ Source or Header  |  1998-09-15  |  2KB  |  76 lines

  1. /*
  2.  * @(#)monitor_cache.h    1.22 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. /*
  16.  * Monitor cache definitions
  17.  */
  18.  
  19. #ifndef _MONITOR_CACHE_H_
  20. #define _MONITOR_CACHE_H_
  21.  
  22. #include "monitor.h"        /* For TIMEOUT_INFINITY */
  23.  
  24. /*
  25.  * There is a distinct recursive lock (not necessarily a monitor) for
  26.  * the monitor cache.
  27.  */
  28. #define CACHE_LOCK_INIT() sysCacheLockInit()
  29. #define CACHE_LOCK()      sysCacheLock()
  30. #define CACHE_LOCKED()      sysCacheLocked()
  31. #define CACHE_UNLOCK()      sysCacheUnlock()
  32.  
  33. /*
  34.  * External routines.
  35.  */
  36. monitor_t *lookupMonitor(unsigned int);
  37. monitor_t *createMonitor(unsigned int);
  38. monitor_t *findMonitor(sys_thread_t *tid, unsigned int key, bool_t create);
  39. void monitorEnumerate(void (*)(monitor_t *, void *), void *);
  40. void monitorEnumerate_unlocked(void (*)(monitor_t *, void *), void *);
  41.  
  42. /*
  43.  * This should probably just be defined as a function but it seems that
  44.  * most of the x86 compilers aren't very agressive inliners and I'd
  45.  * really like this to be inlined.
  46.  */
  47.  
  48. #define checkCache(mon, tid, key) \
  49. { \
  50.     extern int systemIsMP; \
  51.     sys_thread_t * _tid = (tid); \
  52.     unsigned _key = (key); \
  53.     monitor_t * _mon; \
  54.     if (tid) { \
  55.         /* \
  56.          * Stash the key currently being looked up; the monitor in the \
  57.          * global cache for it, even if otherwise unused, is never collected. \
  58.          */ \
  59.         sysCurrentCacheKey(tid) = key; \
  60.         if (systemIsMP) { \
  61.             sysMemoryFlush(); \
  62.         } \
  63.         _mon = sysLocalMonCache(tid, (((key) >> 3) & (SYS_TLS_MONCACHE-1))); \
  64.         if ((_mon != 0) && (_mon->key == key)) { \
  65.             mon = _mon; \
  66.         } else { \
  67.             mon = NULL; \
  68.         } \
  69.     } else \
  70.     mon = NULL; \
  71. }
  72.  
  73.  
  74.  
  75. #endif /* !_MONITOR_CACHE_H_ */
  76.